<template>
    <div class="container">
      <SideBar></SideBar>
      <main class="content">
        <Top></Top>
        <!-- <h1 style="color:#FFF; font-size: 50px;">消息中心</h1> -->
         <div class="contentIn">
          <div class="child_nav_con">

            <div class="user_info">
              <div class="user_head_con">
                <div class="user_head">
                  <img v-if="userState.avatar" :src="userState.avatar" alt="">
                </div>
                <span class="member_tag">会员标签</span>
              </div>
              <h2 class="user_name">{{userState.nickname}}</h2>
              <p class="user_email">用户邮箱（ID）：{{userState.email}}</p>
            </div>

            <div class="message_nav">
              <ul>
                <li 
                  v-for="(item, index) in messageCenterPath" 
                  :key="index"
                  :class="{ active: isActive(item.name) }"
                  >
                  <router-link tag="button" class="item_btn" :to="{name: item.name}" >{{ item.title }}</router-link>
                </li>
              </ul>
            </div>
          </div>
          <div class="message_router">
            <RouterView></RouterView>
          </div>
         </div>
      </main>
    </div>
  </template>
  
  <script setup>
  // 如果需要在 Home 页面处理逻辑可以在这里写
  import { ref, reactive } from 'vue'
  import { useRoute } from 'vue-router'; // 导入 useRoute
  import { useUserStore } from '../../../store/user';
  const { setUsername, setToken, userState } = useUserStore()

  const route = useRoute(); // 获取当前路由信息
  const messageCenterPath = reactive([
    { title: '信息设置', name: 'infoSettings' },
    { title: '修改密码', name: 'changePassword' },
    { title: '修改绑定手机', name: 'bindPhone' },
  ])
  // 判断当前路径是否与给定路径匹配
  function isActive(name) {
      // return route.name.startsWith(path); // 或者使用 route.name === path
      return route.name === name
  }

  </script>
  
  <style scoped>
  .container {
    display: flex; 
    min-height: 100vh; 
    background: linear-gradient(180deg, rgba(30, 30, 64, 1) 0%, rgba(32, 32, 50, 1) 100%);
  }
  
  .content {
    flex: 1; /* 自动填充剩余空间 */
    overflow-y: auto; /* 允许垂直滚动 */
  }

  .contentIn {
    width: 100%;
    padding:30px 0 0 30px;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    background-color: #101030;
    color: #FFF;
  }

  .child_nav_con {
    width: 360px;
    height: 100%;
    background-color: #191938;
  }

  .user_info {
    width: 100%;
    height: 290px;
    background-color: #1e1e3c;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  .user_head_con{
    width: 114px;
    height: 134px;
    position: relative;
  }

  .user_head{
    width: 100%;
    height: 114px;
    background: #d9d9d9 url(../../../images/default_head.png) no-repeat center bottom;
    background-size: 100%;
    border-radius: 100px;
    overflow: hidden;
  }

  .user_head img {
    width: 100%;
    height: 100%;
  }

  .member_tag {
    width: 90px;
    height: 26px;
    line-height: 26px;
    background-color: #d0c13a;
    display: block;
    border-radius: 100px;
    margin: 0 auto;
    text-align: center;
    color: #333;
    font-size: 14px;
    z-index: 1;
    position: absolute;
    bottom: 10px;
    left: 12px;
  }
  
  .user_name{
    height: 40px;
    font-size: 32px;
    margin-top: 10px;
  }
  .user_email{
    font-size: 16px;
    margin-top: 10px;
  }

  .message_nav {
    width: 100%;
    border-top: 2px solid #101030;
    padding: 40px 10px 0 10px;
    box-sizing: border-box;
  }

  .message_nav ul {
    width: 100%;
    
  }

  .message_nav ul li {
    width: 100%;
    height: 50px;
    line-height: 50px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 20px;
  }

  .message_nav ul li.active, .message_nav ul li:hover {
    background-color: rgba(255, 255, 255, 0.16);
  }

  .message_nav ul li a {
    font-size: 20px;
    color: #FFF;
  }

  .message_router {
    flex: 1;
    margin-left: 30px;
    background-color: #191938;
  }

  .item_btn {
    width: 100%;
    height: 100%;
    display: block;
  }

  .msg_container {
    padding: 30px;
    box-sizing: border-box;
  }

  :deep(.el-input-group__prepend ) {
    background: none;
  }

  :deep(.el-select__wrapper) {
      background: none !important;
      border: none !important;
      box-shadow: none;
  }

  :deep(.el-form-item) {
      color: #FFF;
      margin-bottom: 40px;
  }

  :deep(.el-input__wrapper) {
      height: 46px;
      background-color: #59596f;
      border: none;
      box-shadow: 0 0 0 1px #59596f;
  }

  :deep(.el-form-item__label) {
      font-size: 18px;
      color: #FFF;
      line-height: 46px;
  }

  :deep(.el-input__inner) {
      height: 46px;
      font-size: 18px;
      border: none;
      color: #FFF;
  }

  .submit_btn {
    width: 200px;
    height: 40px;
    line-height: 42px;
    text-align: center;
    color: #FFF;
    background-color: #e13f79;
    font-size: 18px;
    border-radius: 5px;
    margin-left: 70px;  
  }
 
  </style>
  